
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Csla
Imports Csla.Data
Imports Csla.Validation

<Serializable()> _
Public Class ro_divisionChild
    Inherits Csla.ReadOnlyBase(Of ro_divisionChild)

#Region " Business Properties and Methods "

    ' declare members
    Private _divisionId As Integer = 0
    Private _divisionName As String = String.Empty
    Private _divisionDescription As String = String.Empty

    ''' <summary>
    ''' Get the DivisionId of the current object.
    ''' </summary>
    ''' <value>A Integer that represents the DivisionId of the current object.</value>
    ''' <returns>Integer representing the return value.</returns>
    ''' <remarks></remarks>
    <System.ComponentModel.DataObjectField(True, True)> _
    Public ReadOnly Property DivisionId() As Integer
        Get
            CanReadProperty("DivisionId", True)
            Return _divisionId
        End Get
    End Property

    ''' <summary>
    ''' Get the DivisionName of the current object.
    ''' </summary>
    ''' <value>A String that represents the DivisionName of the current object.</value>
    ''' <returns>String representing the return value.</returns>
    ''' <remarks></remarks>
    Public ReadOnly Property DivisionName() As String
        Get
            CanReadProperty("DivisionName", True)
            Return _divisionName
        End Get
    End Property

    ''' <summary>
    ''' Get the DivisionDescription of the current object.
    ''' </summary>
    ''' <value>A String that represents the DivisionDescription of the current object.</value>
    ''' <returns>String representing the return value.</returns>
    ''' <remarks></remarks>
    Public ReadOnly Property DivisionDescription() As String
        Get
            CanReadProperty("DivisionDescription", True)
            Return _divisionDescription
        End Get
    End Property

    ''' <summary>
    ''' Get the unique id for the current object.
    ''' </summary>
    ''' <returns>A value that is the unique id of the object.</returns>
    ''' <remarks></remarks>
    Protected Overrides Function GetIdValue() As Object
        Return _divisionId
    End Function

    Public Overrides Function ToString() As String
        Return _divisionName
    End Function

#End Region ' Business Properties and Methods

#Region " Authorization Rules "

    Protected Overrides Sub AddAuthorizationRules()
        'TODO: Define authorization rules in ro_divisionChild
        'AuthorizationRules.AllowRead("DivisionId", "ro_divisionChildReadGroup")
        'AuthorizationRules.AllowRead("DivisionName", "ro_divisionChildReadGroup")
        'AuthorizationRules.AllowRead("DivisionDescription", "ro_divisionChildReadGroup")

    End Sub

#End Region ' Authorization Rules

#Region " Factory Methods "

    Friend Shared Function Getro_divisionChild(ByVal dr As SafeDataReader) As ro_divisionChild
        Return New ro_divisionChild(dr)
    End Function

    Private Sub New(ByVal dr As SafeDataReader)
        Fetch(dr)
    End Sub

#End Region ' Factory Methods

#Region " Data Access "

#Region " Data Access - Fetch "

    Private Sub Fetch(ByVal dr As SafeDataReader)
        FetchObject(dr)

        'load child object(s)
        FetchChildren(dr)
    End Sub

    Private Sub FetchObject(ByVal dr As SafeDataReader)
        _divisionId = dr.GetInt32("divisionId")
        _divisionName = dr.GetString("divisionName")
        _divisionDescription = dr.GetString("divisionDescription")
    End Sub

    Private Sub FetchChildren(ByVal dr As SafeDataReader)
    End Sub

#End Region ' Data Access - Fetch

#End Region

End Class

